package com.rt.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rt.common.annotation.Log;
import com.rt.common.core.controller.BaseController;
import com.rt.common.core.domain.AjaxResult;
import com.rt.common.enums.BusinessType;
import com.rt.system.domain.RtDifficultyLogMain;
import com.rt.system.service.IRtDifficultyLogMainService;
import com.rt.common.utils.poi.ExcelUtil;
import com.rt.common.core.page.TableDataInfo;

/**
 * 难易度调整日志（主）Controller
 * 
 * @author Yg
 * @date 2022-04-21
 */
@RestController
@RequestMapping("/system/main")
public class RtDifficultyLogMainController extends BaseController
{
    @Autowired
    private IRtDifficultyLogMainService rtDifficultyLogMainService;

    /**
     * 查询难易度调整日志（主）列表
     */
    @PreAuthorize("@ss.hasPermi('system:main:list')")
    @GetMapping("/list")
    public TableDataInfo list(RtDifficultyLogMain rtDifficultyLogMain)
    {
        startPage();
        List<RtDifficultyLogMain> list = rtDifficultyLogMainService.selectRtDifficultyLogMainList(rtDifficultyLogMain);
        return getDataTable(list);
    }

    /**
     * 导出难易度调整日志（主）列表
     */
    @PreAuthorize("@ss.hasPermi('system:main:export')")
    @Log(title = "难易度调整日志（主）", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RtDifficultyLogMain rtDifficultyLogMain)
    {
        List<RtDifficultyLogMain> list = rtDifficultyLogMainService.selectRtDifficultyLogMainList(rtDifficultyLogMain);
        ExcelUtil<RtDifficultyLogMain> util = new ExcelUtil<RtDifficultyLogMain>(RtDifficultyLogMain.class);
        return util.exportExcel(list, "难易度调整日志（主）数据");
    }

    /**
     * 获取难易度调整日志（主）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:main:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rtDifficultyLogMainService.selectRtDifficultyLogMainById(id));
    }

    /**
     * 新增难易度调整日志（主）
     */
    @PreAuthorize("@ss.hasPermi('system:main:add')")
    @Log(title = "难易度调整日志（主）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RtDifficultyLogMain rtDifficultyLogMain)
    {
        return toAjax(rtDifficultyLogMainService.insertRtDifficultyLogMain(rtDifficultyLogMain));
    }

    /**
     * 修改难易度调整日志（主）
     */
    @PreAuthorize("@ss.hasPermi('system:main:edit')")
    @Log(title = "难易度调整日志（主）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RtDifficultyLogMain rtDifficultyLogMain)
    {
        return toAjax(rtDifficultyLogMainService.updateRtDifficultyLogMain(rtDifficultyLogMain));
    }

    /**
     * 删除难易度调整日志（主）
     */
    @PreAuthorize("@ss.hasPermi('system:main:remove')")
    @Log(title = "难易度调整日志（主）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtDifficultyLogMainService.deleteRtDifficultyLogMainByIds(ids));
    }
}
